<extend name="_layout/main" />
<block name="head">
<block name="head">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/assets/css/jasny-bootstrap.min.css" />
	<style type="text/css">
		#pic~i{ display: none!important;}
	</style>
</block>
</block>
<block name="content">
	<div class="page-content">
		<div class="page-breadcrumbs">
			<ul class="breadcrumb">
				<li>
					<i class="fa fa-home"></i>
					<a href="{:U('dashboard/index')}">系统首页</a>
				</li>
				<li>
					幻灯片管理
				</li>
				<li>
					{$slider_info['name']}
				</li>
				<li class="active">编辑图片</li>
			</ul>
		</div>
		<div class="page-body">
			<div class="row">
				<div class="col-xs-12 col-md-12">
					<div class="widget">
						<div class="widget-header bordered-bottom bordered-blue">
							<span class="widget-caption">编辑图片</span>
						</div>
						<div class="widget-body">
							<div>
								<form class="form-horizontal" action="{:U('slider/item_edit')}" method="post" id="addForm" onsubmit="return false;" enctype="multipart/form-data">
									<input type="hidden" name="id" value="{$id}" />
									<div class="form-group">
										<label for="title" class="col-sm-2 control-label no-padding-right">标题</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" id="title" name="title" placeholder="" value="{$title}">
										</div>
									</div>
									<div class="form-group">
										<label for="link" class="col-sm-2 control-label no-padding-right">链接地址</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" id="link" name="link" placeholder="" value="{$link}">
										</div>
									</div>

									<div class="form-group">
										<label for="link" class="col-sm-2 control-label no-padding-right">内容说明</label>
										<div class="col-sm-3">
											<textarea class="form-control" name="content" id="content" rows="3">{$content}</textarea>
										</div>
									</div>
									
									<div class="form-group">
										<label for="date_range" class="col-sm-2 control-label no-padding-right">有效期</label>
										<div class="col-sm-3">
											<input type="hidden" name="start_time" id="start_time" value="{:date('m/d/Y',$start_time)}" />
											<input type="hidden" name="end_time" id="end_time" value="{:date('m/d/Y',$end_time)}" />
											<input type="text" class="form-control" id="date_range" name="date_range" placeholder="" value="{:date('m/d/Y',$start_time)} - {:date('m/d/Y',$end_time)}">
										</div>
									</div>
									<div class="form-group">
										<label for="category" class="col-sm-2 control-label no-padding-right">图片</label>
										<div class="col-sm-3">
											<div class="fileinput fileinput-new" data-provides="fileinput">
												<div class="fileinput-new thumbnail" style="width: 300px; height: 100px;"> <img src="{$pic}" data-src="holder.js/285x90?text=图片&theme=gray"> </div>
												<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 300px; max-height: 100px;"></div>
												<div> <span class="btn btn-default btn-file"><span class="fileinput-new">选择</span> <span class="fileinput-exists">重新选择</span>
													<input type="file" name="pic" id="pic">
													</span> <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">删除</a> </div>
											</div>
										</div>
									</div>

									<div class="form-group">
										<div class="col-sm-offset-2 col-sm-10">
											<button type="submit" class="btn btn-blue ladda-button" data-style="expand-right" id="submitBtn"> <span class="ladda-label">确认保存</span></button>
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>

<block name="footer">
	<script src="__PUBLIC__/assets/js/fuelux/spinbox/fuelux.spinbox.min.js"></script>
	<script src="__PUBLIC__/assets/js/validation/bootstrapValidator.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/holder.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/jasny-bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	<!--Bootstrap Date Range Picker-->
	<script src="__PUBLIC__/assets/js/datetime/moment.js"></script>
	<script src="__PUBLIC__/assets/js/datetime/zh-cn.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/datetime/daterangepicker.js"></script>

	<script type="text/javascript">
		moment.lang('zh-cn');
		$('#date_range').daterangepicker({
			locale: {
				applyLabel: '确定',
				cancelLabel: '取消'
			},
			startDate:"{:date('m/d/Y')}",
			endDate:"{:date('m/d/Y',strtotime('+10 years'))}"
		},function(start,end,label){ 
			$("#start_time").val(start.format('MM/DD/YYYY'));
			$("#end_time").val(end.format('MM/DD/YYYY'));
		});
		
		
		var loader = Ladda.create(document.getElementById("submitBtn"));
		$('.spinbox').spinbox({
			min: 1,
			max: 99
		});
		$("#addForm").bootstrapValidator({
			excluded: [':disabled'],
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			live:'disabled',
			submitHandler:function(validator,form,submitButton){
				loader.start();
				$("#addForm").ajaxSubmit(function(result){	
					loader.stop();
					result = JSON.parse(result);
					if(result.status == 'success'){ 
						location.href = "{:U('slider/item',['slider_id'=>$slider_id])}";
					}else{					
						tips(result.message,'danger');
						validator.disableSubmitButtons(false);
						
					}
				});
					
			}
		})
	</script>
</block>